<!DOCTYPE html>
<html>


<head>

    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
    <title>道具商店</title>

    <link href="http://css.mafengwo.net/css/cv/css+base:css+jquery.suggest:css+plugins:css+plugins+jquery.jgrowl:css+other+popup:css+app+topbar_v2^alw^1542357401.css" rel="stylesheet" type="text/css"/>

    <script type="text/javascript">
        window.Env = {"WWW_HOST":"www.mafengwo.cn","IMG_HOST":"images.mafengwo.net","W_HTTP":"http:\/\/w.mafengwo.cn","P_HOST":"passport.mafengwo.cn","P_HTTP":"https:\/\/passport.mafengwo.cn","PAGELET_HTTP":"http:\/\/pagelet.mafengwo.cn","JS_HOST":"js.mafengwo.net","TONGJI_HOST":"tongji.mafengwo.cn","UID":94900161,"CSTK":"18619fdda7a7884f0527967531d16a2d_8ff4cef0ffbfa3dcba0a1113b7ece0ee","GOOGLE_MAP_KEY":"AIzaSyD-Su0x_rPy1xehlMBcMyTqWkU49Bk53nQ","MOBILE_BINDED":true};
    </script>

    <link href="http://css.mafengwo.net/css/cv/css+base:css+jquery.suggest:css+plugins:css+plugins+jquery.jgrowl:css+other+popup:css+app+topbar_v2^alw^1542357401.css" rel="stylesheet" type="text/css"/>



    <script language="javascript" src="http://js.mafengwo.net/js/cv/js+jquery-1.8.1.min:js+global+json2:js+M+Module:js+M+M:js+M+Log:js+m.statistics:js+advert+inspector^alw^1563531411.js" type="text/javascript" crossorigin="anonymous"></script>
    <script type="text/javascript">
        var __mfw_uid = parseInt('94900161');
    </script>
    <script language="javascript" src="http://js.mafengwo.net/js/cv/js+common+jquery.plugins:js+common+widgets:js+mfw.storage^ZlI^1537192880.js" type="text/javascript" crossorigin="anonymous"></script>
    <link href="http://css.mafengwo.net/css/daoju.css?1537192876" rel="stylesheet" type="text/css"/>
    <script language="javascript" src="http://js.mafengwo.net/js/cv/js+hb+hb:js+hb+common:js+hb+Request:js+m.sns.share:js+qa+common^ZVY^1555913877.js" type="text/javascript" crossorigin="anonymous"></script>
    <script type="text/javascript" src="../js/plugins/jquery-form/jquery.form.js"></script>
    <style type="text/css">
        m {
            position:absolute;
        }
    </style>
    <script type="text/javascript" src="/js/plugins/jqPaginator/jq-paginator.min.js"></script>
</head>
<body>
<form class="form-horizontal" action="/itemshop/buy" method="post" id="buyForm">
    <input id="itemId" type="hidden" value="0" name="id">

</form>
<#--<m id="coin"><img src="../images/coin.gif" height="200" width="200"/></m>-->
<script type="text/javascript" language="javascript">
    <#--$(function () {-->
    <#--    //获取图片所在的div对象-->
    <#--    var pic = document.getElementById('coin');-->

    <#--    var w=document.body.clientWidth,h=document.body.clientHeight+500; //窗口的大小-->
    <#--    //产生随机坐标-->
    <#--    var x = Math.random()*w;-->

    <#--    //var y = Math.random()*h;-->
    <#--    var y = 5;-->

    <#--    //图片的定位-->
    <#--    pic.style.left=x+"px";-->

    <#--    pic.style.top=y+"px";-->

    <#--    $("#coin").click(function () {-->
    <#--        this.remove();-->

    <#--        if (confirm("恭喜你获得一次抽奖机会")) {-->
    <#--            $.get("/itemshop/coin", function(data){});-->
    <#--            window.location.href='/js/jquery-lhj/index.html'-->
    <#--        }-->
    <#--        else {-->

    <#--        }-->

    <#--        // $("#gold").html('<i></i>'+(${(userInfo.score)!}+data.data))-->

    <#--    })-->
    })

</script>

<div class="topBar">
    <div class="topBarC">
        <div class="logo"><a title="自由行" href="http://127.0.0.1">自由行</a></div>
        <div class="t_nav">
            <ul id="pnl_nav" data-cs-t="headnav_wo">
                <li data-cs-p="index">
                    <strong class="t"><a href="http://127.0.0.1">首页</a></strong>
                </li>
                <li data-cs-t="wenda" data-cs-p="wenda">
                    <strong class="t"><a data-cs-p="from_wo_nav" href="/wenda/">问答</a></strong>
                </li>
                <li data-cs-t="things" data-cs-p="things">
                    <strong class="t"><a data-cs-p="from_wo_nav" href="/mall/things.php">周边</a></strong>
                </li>
                <li data-cs-p="together">
                    <strong class="t"><a href="/together/">结伴</a></strong>
                </li>
                <li data-cs-p="group">
                    <strong class="t"><a href="/group/">小组</a></strong>
                </li>
                <li data-cs-p="mall">
                    <strong class="t"><a href="/club/">俱乐部</a></strong>
                </li>
                <li class="drop" data-cs-p="other">
                    <strong class="t"><a href="/app/hun.php">更多<b></b></a></strong>
                    <div class="c">
                        <a href="/focus/" target="_blank">真人兽</a>
                        <a href="/school/" target="_blank">马蜂窝高校</a>
                        <a href="/photo_pk/prev.php" target="_blank">照片PK</a>
                        <a href="/auction/" target="_blank">马蜂窝拍卖行</a>
                        <a href="/mall/virtual_goods.php" target="_blank">道具商店</a>
                        <a href="/radio/" target="_blank">旅行电台</a>
                        <a href="/club/" target="_blank">蜂首聚乐部</a>
                        <a href="/home/vip_show.php" target="_blank">VIP</a>
                        <a href="/game/wager.php" target="_blank">分歧终端机</a>
                    </div>
                </li>
            </ul>
        </div>
        <div class="t_search">
            <form method="GET" action="/search/s.php" name="search">
                <input type="text" class="key" value="" name="q" id="word">
                <input type="submit" value="" class="btn">
            </form>
        </div>

        <div class="t_info">
            <div data-pagelet id="pagelet-block-2d7ace2c07b64c50aca930ff4a543d39" class="" data-api="apps:user:pagelet:pageViewHeadInfo" data-params="{&quot;type&quot;:2}" data-async="1" data-controller="/js/pageletcommon/pageHeadUserInfoWWWDark"></div>
        </div>
    </div>
</div>



<div class="container">

    <div class="mt-nav clearfix">

    </div>


    <!-- banner -->
    <div class="banner">
        <img src="http://images.mafengwo.net/images/daoju/banner.jpg" alt="">
    </div>

    <div class="row clearfix">
        <div class="col-main">

            <div class="daoju_tab">
                <a id="shop" class="active _j_goods_tab" data-index="0">道具商店</a>
                <#if userInfo ??>
                <a class="_j_goods_tab"        data-index="1">我的道具</a>
                </#if>
                <strong style="left: 0px"></strong>
            </div>
            <div id="itemBox" class="daoju_list  _j_goods_list" data-flag="0" data-total="2">
                <li class="_j_goods_li">
                    <#--<div class="info">
                        <a href="http://www.mafengwo.cn/i/5572235.html" target="_blank">
                            <img src="http://b3-q.mafengwo.net/s9/M00/D0/FC/wKgBs1eQOmaACRA-AAA3GcTdIkI593.png?imageMogr2%2Fthumbnail%2F%21298x298r%2Fgravity%2FCenter%2Fcrop%2F%21298x298%2Fquality%2F100"
                                 alt="神奇逗猫棒">
                            <div class="name">神奇逗猫棒<span>剩余0</span></div>
                            <i class="state1"></i>
                        </a>
                    </div>
                    <div class="buy">
                        <span><i class="icon_gold"></i>10000</span>
                        <a class="btn_buy ">购买</a>
                    </div>-->
                </li>
            </div>
            <div class="pagin" id="smallpager"></div>

        </div>
        <div class="col-side">

            <div class="side_my">
                <p>你的金币</p>
                <div id="gold" class="gold"><i></i>${(userInfo.score)!0}</div>
            </div>

            <div class="side_cmt">
                <div class="tit"></div>
                <div class="con">
                    <div id="_j_comment_cnt">
                        <div class="addComment clearfix">
                            <div class="pub">
                                <textarea id="textarea" class="_j_comment_pubarea"></textarea>
                                <input type="button" class="_j_comment_pubbtn" value="发表留言">
                            </div>
                        </div>

                        <div class="commentList _j_comment_list"></div>
                        <div class="page _j_comment_pagination"></div>


                        <ul id="cmt_list" class="cmt_list">

                            <#--<li class="_j_citem" data-uid="10" data-username="秋刀鱼223">
                                <a href="" class="photo"><img src="/images/1.jpg"></a>
                                <a href="" class="user">秋刀鱼223</a>
                                <a href="" class="level">LV.98</a>
                                <a href="#" class="_j_reply">回复</a>
                                <span class="date">2019-7-22 17:18:17</span>
                                <p>555</p>
                            </li>
                            <li class="_j_citem" data-uid="12" data-username="秋刀鱼223">
                                <a href="" class="photo"><img src="/images/1.jpg"></a>
                                <a href="" class="user">秋刀鱼223</a>
                                <a href="" class="level">LV.98</a>
                                <a href="#" class="_j_reply">回复</a>
                                <span class="date">2019-7-22 17:17:34</span>
                                <p>555</p>
                            </li>-->


                            <#--{{each(i, comment) comment_list}}
                                <li class="_j_citem" data-cid="${comment.id}" data-username="${comment.user.name}">
                                    <a href="/u/${comment.uid}.html" class="photo"><img src="${comment.user.logo_48}"></a>
                                    <a href="/u/${comment.uid}.html" class="user">${comment.user.name}</a>
                                    <a href="/u/${comment.uid}.html" class="level">LV.${comment.user.user_lv}</a>
                                    <a href="#" class="_j_reply">回复</a>
                                    <span class="date">${comment.ymdhitime}</span>
                                    <p>${comment.content}</p>
                                </li>
                            {{/each}}-->
                        </ul>




                        <script>
                            M.closure(function (require) {
                                var MComment = require("/js/activity/MComment");
                                new MComment({
                                    "objid": "0",
                                    "pubLogoSize": "w48",
                                    "containerID": "_j_comment_cnt",
                                    "commentItemTmpl": "_j_comment_item",
                                    "id": "activity_comment",
                                    "appid": "70",
                                    "pagiTmpl": "_j_pagitmpl",
                                    "pageSize": "6",
                                    "pageDisplayNum": "1",
                                    "_uid": "94900161"
                                });
                            });
                        </script>

                    </div>

                </div>
            </div>
        </div>
    </div>
</div>

<#--<script type="text/x-jquery-tmpl" id="_j_pagitmpl">
{{if pageTotal > 1}}
   <div class="pagin">
        <span>${currPage}/${pageTotal}</span>
            {{if currPage > 1}}
        <a title="上一页" href="#" class="btn-left _j_pageitem" data-page="${currPage - 1}"></a>
            {{/if}}
                {{if currPage < pageTotal}}
        <a title="下一页" href="#" class="btn-right _j_pageitem" data-page="${currPage + 1}"></a>
            {{/if}}
    </div>
{{/if}}
</script>-->
<#--<script type="text/x-jquery-tmpl" id="pagination_tmpl">
{{if pageTotal > 1}}
<div align="right" class="page-box">
    <span class="count">共<span>${pageTotal}</span>页 / <span>${total}</span>条</span>
    {{if currPage > 1}}
    <a class="ti prev _j_pageitem" data-page="${currPage - 1}">前一页</a>
    {{/if}}
    {{if indexers[indexers.length-1] > 10}}
    <a class="ti _j_pageitem" data-page="1">1...</a>
    {{/if}}
    {{each(i, index) indexers}}
    {{if index == currPage}}
    <span class="ti this-page">${index}</span>
    {{else}}
    <a class="ti _j_pageitem" data-page="${index}">${index}</a>
    {{/if}}
    {{/each}}
    {{if indexers[indexers.length-1] < pageTotal}}
    <a class="ti _j_pageitem" data-page="${pageTotal}">...${pageTotal}</a>
    {{/if}}
    {{if currPage < pageTotal}}
    <a class="ti next _j_pageitem" data-page="${currPage + 1}">后一页</a>
    {{/if}}
</div>
{{/if}}
    </script>-->



<script>
    M.closure(function(require){
        var Alert = require('dialog/alert'),
            Confirm = require('dialog/confirm');

        // page
        var Pagination = require('Pagination'),
            page = new Pagination({
                'container': '#smallpager',
                'tmpl': '#pagination_tmpl',
                'total': $('._j_goods_list').data('total'),
                'pageSize': 6,
                'pageDisplayNum': 4,
                'callback': function(pageIndex) {
                    goodsList(pageIndex);
                }
            });
        page.drawPage();

        var flag = $('._j_goods_list').data('flag');
        $('._j_goods_tab').click(function(ev){
            var index = $(ev.currentTarget).data('index');
            if(index != flag){
                flag = index;
                $('._j_goods_tab').removeClass('active');
                $(ev.currentTarget).addClass('active');
                $(ev.currentTarget).siblings('strong').animate({left:180*flag},300);
                goodsList(0);
            }
        });

        function goodsList(page){
            $.get('/mall/ajax_virtual_goods/list',{ 'flag':flag,'page':page},function(res){
                if(!res.error && res.data.html){
                    $('._j_goods_list').html(res.data.html);
                    resetPage(page,res.data.total);
                    if(flag == 1 && res.data.total == 0){
                        $('._j_goods_list').html('<div class="daoju_none">\
                                <img src="http://images.mafengwo.net/images/daoju/none.png" alt="">\
                                <p>你还没有购买过任何道具哦~</p>\
                        </div>');
                    }
                }
            },'json');
        }

        function resetPage(pageIndex, total) {
            pageIndex = pageIndex ? pageIndex : pageIndex + 1;
            page.currPage = pageIndex;
            if(total > 0) {
                $('#smallpager').show();
                page.total = total;
            }else{
                $('#smallpager').hide();
            }
            page.drawPage();
        }

        var uid = window.Env.UID,
            canClick = true;
        $('._j_goods_list').delegate('._j_buy','click',function(ev){
            if(!uid){
                window.location.href = 'https://passport.mafengwo.cn/';
            }
            var id = $(ev.currentTarget).data('id');
            if(id){
                Confirm.pop('确认购买？',function(){
                    if(canClick){
                        canClick = false;
                        $.post('/mall/ajax_virtual_goods/buy',{ 'id':id,'num':1},function(res){
                            if(!res.error && res.data.data){
                                if(res.data.data.check == 0){
                                    Alert.pop('请联系管理员');
                                }else if(res.data.data.check == 2){
                                    Alert.pop('购买的商品已下架');
                                }else if(res.data.data.check == 3){
                                    Alert.pop('购买的商品无足够库存');
                                }else if(res.data.data.check == 4){
                                    Alert.pop('你已超过改商品的购买次数');
                                }else if(res.data.data.check == 5){
                                    Alert.pop('不能超过该商品的拥有数量');
                                }else if(res.data.data.check == 6){
                                    Alert.pop('你的金币不够');
                                }else if(res.data.data.check == 7){
                                    Alert.pop('你的蜂蜜不够');
                                }else{
                                    Alert.pop('购买成功','',3);
                                    window.location.href = '/mall/virtual_goods.php?flag=1';
                                }
                            }
                            canClick = true;
                        });
                    }
                });
            }
        }).delegate('._j_not_buy','click',function(){
            Alert.pop('不能购买');
        }).delegate('._j_not_buy_times','click',function(){
            Alert.pop('此道具你已超过购买次数');
        }).delegate('._j_not_use','click',function(){
            Alert.pop('不能使用');
        });

        M.Event.on('virtual_goods_used',function(agr){
            var orderId = agr.order_id,
                userNum = agr.used_num,
                nowNuM = $('._j_order_'+orderId+'').find('._j_can_user_num').data('num'),
                num = nowNuM - userNum ? nowNuM - userNum : 0;
            $('._j_order_'+orderId+'').find('._j_can_user_num').html('可用'+num);
        });


        //============================================================这里是自己写的
        $(".daoju_tab a").click(function () {
            $("#queryType").val($(this).data("index"))

            $("#itemForm").ajaxSubmit(function (data) {
                //console.log(data);
                $("#itemBox").html(data);

                //绑定购买的点击事件
                $(".buy .btn_buy").click(function () {
                    var id = $(this).data("id");
                    var name = $(this).data("name");
                    Confirm.pop('确认购买'+name+"商品",function(){
                        if(canClick){
                            //console.log("123");
                            $("#itemId").val(id);
                            //Confirm.pop(id);
                            //itemId
                            $("#buyForm").ajaxSubmit(function (data) {
                                if(data.success!=true){
                                    Alert.pop(data.msg,function(){
                                        if(canClick){
                                            if(data.code == 403)
                                            window.location="http://127.0.0.1/login.html";
                                        }

                                    });

                                }else{
                                    Alert.pop("已经装入你的百宝袋",function(){
                                        if(canClick){
                                            console.log(1);
                                            window.location="http://127.0.0.1/mall/mall";
                                        }
                                    });

                                }

                            })
                            //window.location.href = '/mall/itemshop/list
                            //location.reload();

                        }
                    })
                })
            })

        })


        //初始化
        $("#shop").click();

        //点击回复触发文本框选中事件并填充内容

        $("._j_citem").click(function () {
            $("#toId").val($(this).data("uid"));
            $("#textarea").val("回复@"+$(this).data("username")+":").focus();

        });

        //发表留言
        $("._j_comment_pubbtn").click(function () {
            //Alert.pop(123);
            //content
            $("#content").val($("#textarea").val());

            //提交表单
            $("#commentForm").ajaxSubmit(function (data) {
                //Alert.pop("评论成功");
                $("#cmt_list").html(data);
                $("#textarea").val("");

                $("._j_citem").click(function () {
                    $("#toId").val($(this).data("uid"));
                    $("#textarea").val("回复@"+$(this).data("username")+":").focus();

                });

            })


        });

        $("._j_comment_pubbtn").click();




    });
</script>

<link href="http://css.mafengwo.net/css/mfw-footer.css?1558532347" rel="stylesheet" type="text/css"/>

<link href="http://css.mafengwo.net/css/mfw-toolbar.css?1537192876" rel="stylesheet" type="text/css"/>

<script language="javascript" type="text/javascript">
    if (typeof M !== "undefined" && typeof M.loadResource === "function") {
        M.loadResource("http://js.mafengwo.net/js/cv/js+pageletcommon+pageHeadUserInfoWWWDark:js+jquery.tmpl:js+M+module+FrequencyVerifyControl:js+M+module+FrequencyAppVerify:js+M+module+Pagination:js+activity+MComment:js+M+module+dialog+Layer:js+M+module+dialog+DialogBase:js+M+module+dialog+Dialog:js+M+module+dialog+alert:js+M+module+dialog+confirm:js+M+module+PageAdmin:js+M+module+Storage:js+M+module+Cookie:js+M+module+ResourceKeeper:js+jquery.jgrowl.min:js+AMessage:js+M+module+FrequencySystemVerify:js+ALogin:js+M+module+ScrollObserver:js+M+module+QRCode:js+AToolbar:js+ACnzzGaLog:js+ARecruit:js+ALazyLoad^ZlNT^1561616124.js");
    }
</script>
<form class="form-horizontal" action="/itemshop/query" method="post" id="itemForm">
    <input id="queryType" type="hidden" value="0" name="queryType">

</form>
<form class="form-horizontal" action="/itemshop/comment" method="post" id="commentForm">
    <input id="toId" type="hidden" value="-1" name="toId">
    <input id="content" type="hidden" value="0000" name="content">
</form>

</body>
<#include "../common/footer.ftl">
</html>